package com.mercycrazy.recruit.converter;

import com.mercycrazy.recruit.enums.Sex;

import javax.persistence.AttributeConverter;

/**
 * 性别枚举属性转换器
 *
 * @author <a href="mailto:1443424326@qq.com">mercycrazy</a>
 * @see Sex
 * @since 2023-01-15
 */
public class SexConverter implements AttributeConverter<Sex, Integer> {

    @Override
    public Integer convertToDatabaseColumn(Sex sex) {
        return sex.getType();
    }

    @Override
    public Sex convertToEntityAttribute(Integer type) {
        return Sex.of(type);
    }
}
